output = open("字符串的格式化练习.txt", "w", encoding="utf-8")
content = """
#format
a = "ping"
b = "pong"
print("play pingpong: {}, {}".format(a, b))


#按指定的参数索引
a = "ping"
b = "pong"
print("play pingpong: {0}, {1}, {1}".format(a, b))


#按关键词参数索引
a = "ping"
b = "pong"
print("play pingpong: {a}, {b}, {b}".format(a = "ping", b = "321"))


#按照变量
a = "ping"
b = "pong"
print(f"playing pingpong: {a}, {b}")


#小数的表示{:.2f}
print("{:.2f}".format(3.45666))


#%
"playing %s %s" % ("ping", "pong")
'playing ping pong'

"""

output.write(content)
output.close()

